#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1e5 + 5;

int n, m;
int a[N];
ll b[N], c[N];
int pos[N];
int l[505], r[505];
ll d[505];
void init() {
  int k = sqrt(m);
  rep(i, 1, m) pos[i] = (i - 1) / k + 1;
  int cnt = pos[m];
  rep(i, 1, cnt) {
    l[i] = (i - 1) * k + 1;
    r[i] = i * k;
  }
  r[cnt] = m;
}
void update_inb(int L, int R, int x) {
  int id = pos[L];
  rep(i, L, R) b[i] += x;
  rep(i, l[id], r[id]) c[i] = b[i];
  sort(c + l[id], c + r[id] + 1);
}
void update(int L, int x) {
  int id = pos[L];
  if (id == pos[m]) {
    update_inb(L, m, x);
    return;
  }
  update_inb(L, r[id], x);
  rep(i, id + 1, pos[m]) d[i] += x;
}
int query(int R, ll x) {
  int res = x <= 0 ? 1 : 0;
  if (R <= 0) return res;
  int id = pos[R];
  rep(i, 1, id - 1) {
    res += c + r[i] + 1 - lower_bound(c + l[i], c + r[i] + 1, x - d[i]);
  }
  rep(i, l[id], R) if (b[i] >= x - d[id]) res++;
  return res;
}
struct Query {
  int t, p, x, id;
  bool operator<(Query q) const { return p < q.p; }
} q[N];
struct Update {
  int t, p, x;
  bool operator<(Update u) const { return p < u.p; }
} u[N << 1];
int qnum, unum, ans[N];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  init();
  rep(i, 1, n) cin >> a[i];
  rep(i, 1, m) {
    int op;
    cin >> op;
    if (op == 1) {
      int l, r, x;
      cin >> l >> r >> x;
      u[++unum] = Update{i, l, x};
      u[++unum] = Update{i, r + 1, -x};
    } else {
      int p, x;
      cin >> p >> x;
      qnum++;
      q[qnum] = Query{i, p, x, qnum};
    }
  }
  sort(q + 1, q + qnum + 1);
  sort(u + 1, u + unum + 1);
  int j = 1;
  rep(i, 1, qnum) {
    while (j <= unum && u[j].p <= q[i].p) {
      update(u[j].t, u[j].x);
      j++;
    }
    ans[q[i].id] = query(q[i].t - 1, q[i].x - a[q[i].p]);
  }
  rep(i, 1, qnum) cout << ans[i] << endl;
  return 0;
}